<script setup>
import { provide, ref,inject,reactive } from 'vue';
import { Edit, Delete,Check,Close } from '@element-plus/icons-vue'

//引入axios
const axios = inject('axios')

//数据
const testdata = reactive({
  "orderCheck": [],
})


//发送请求时的附带数据
const Data = reactive({
  "conditions": { "productionNoOrProductNo":"" }
})

//获取所有数据
function selectOrderCheck() {
  axios({
    method: 'post',
    url: '/api/orderCheck/selectOrderCheck',
    // data: Data
  }).then((response) => {
    if (response.data.success) {
      if (response.data.map.order_check != null) {
        testdata.orderCheck = response.data.map.order_check
        console.log("result:")
        console.log(response.data.map)
        console.log("testdata.orderCheck:")
        console.log(testdata.orderCheck)
        // myData.pageParams = response.data.map.pageParams
      } else {
        ElMessageBox.alert("无订单记录！", '结果')
      }
    } else {
      ElMessageBox.alert(response.data.msg, '结果')
    }
  }).catch((error) => {
    ElMessageBox.alert("系统错误！", '结果')
  })
}
selectOrderCheck()

//按条件获取数据
function selectByNum() {
  console.log("Data:")
  console.log(Data)
  axios({
    method: 'post',
    url: '/api/orderCheck/selectByNum?num='+Data.conditions.productionNoOrProductNo,
  }).then((response) => {
    if (response.data.success) {
      if (response.data.map.order_check != null) {
        testdata.orderCheck = response.data.map.order_check
        console.log("result:")
        console.log(response.data.map)
        console.log("testdata.orderCheck:")
        console.log(testdata.orderCheck)
        // myData.pageParams = response.data.map.pageParams
      } else {
        ElMessageBox.alert("无订单记录！", '结果')
      }
    } else {
      ElMessageBox.alert(response.data.msg, '结果')
    }
  }).catch((error) => {
    ElMessageBox.alert("系统错误！", '结果')
  })
}

//表单序号自增
const indexMethod = (index) => {
  return index + 1
}

</script>
<template>
  <el-row style="background-color:white;margin:10px 10px 0 10px">
    <el-col :span="3" style="margin:10px 0 0 10px">订单列表</el-col>
  </el-row>
  <el-row style="background-color:white;margin:0 10px 0 10px">
    <el-col :span="2" style="margin:10px 0 0 10px">
      <el-button :icon="Refresh">刷新</el-button>
    </el-col>
    <el-col :span="19" style="margin-top:10px">
      <el-input v-model="Data.conditions.productionNoOrProductNo" placeholder="请输入生产序号或产品货号" />
    </el-col>
    <el-col :span="2" style="margin-top:10px">
      <el-button type="success" @click="selectByNum">搜索</el-button>
    </el-col>
  </el-row>
  <el-row style="background-color:white;margin:0 10px 0 10px">
    <el-col :span="24" style="margin-top:15px">
      <!--斑马纹效果  带边框 -->
      <el-table :data="testdata.orderCheck" stripe border style="width:100%">
        <el-table-column label="序号" align="center" type="index" :index="indexMethod" width="100"></el-table-column>
        <el-table-column label="生产序号" align="center" prop="productionNo" width="120" />
        <el-table-column label="订单产品货号" align="center" prop="orderProductNo" width="120" />
        <el-table-column label="计划生产数量" align="center" prop="planProductionQuantity" width="120" />
        <el-table-column label="订单状态" align="center" prop="orderState" width="120" />
        <el-table-column label="首件检测" align="center" prop="firstInspection" width="120" />
        <el-table-column label="检测数量" align="center" prop="inspectionQuantity" width="160" />
        <el-table-column label="检测是否通过" align="center" prop="pass" width="120" />
        <el-table-column label="操作" align="center" style="text-align: center;">
          <template #default="scope">
            <el-button type="primary" :icon="Edit" size="small">编辑</el-button>
          </template>
        </el-table-column>
      </el-table>
    </el-col>
  </el-row>
</template>
<style scoped>

</style>